package darknet.core.spec.net;

import java.io.IOException;


/**
 * A protocol handler, able to handle some message from a protocol.
 * 
 * @author yoyo
 */
public interface ProtocolHandler {

    /**
     * Return true if this protocol handler can handle a message, 
     * false otherwise.
     * 
     * @param toHand The message to hand.
     * @return
     */
    boolean canHandle(Message toHand);
    
    /**
     * Hand a given message.
     * 
     * @param toHand The message to hand.
     */
    void handle(StreamableMessage toHand) throws IOException;
}
